package javaBase.nowcoder.HJ22_A_汽水瓶_三换一;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class HJ22 {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while ((str = bufferedReader.readLine()) != null) {
            int n = Integer.parseInt(str);
            if (n == 0) return;
            int count = 0;
            while (n != 0) {
                count += n / 3;
                n = (n % 3) + (n / 3);
                if (n < 3) {
                    break;
                }
            }
            if (n == 2) count++;
            System.out.println(count);
        }
    }
}
